package com.ruoyi.system.controller;

import java.util.List;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.api.domain.SchoolPayrecordd;
import com.ruoyi.system.service.ISchoolPayrecorddService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * 缴费记录明细Controller
 * 
 * @author ruoyi
 * @date 2023-02-09
 */
@RestController
@RequestMapping("/payrecordd")
public class SchoolPayrecorddController extends BaseController
{
    @Autowired
    private ISchoolPayrecorddService schoolPayrecorddService;

    /**
     * 查询缴费记录明细列表
     */
    @RequiresPermissions("business:payrecordd:list")
    @GetMapping("/list")
    public TableDataInfo list(SchoolPayrecordd schoolPayrecordd)
    {
        startPage();
        List<SchoolPayrecordd> list = schoolPayrecorddService.selectSchoolPayrecorddList(schoolPayrecordd);
        return getDataTable(list);
    }

    /**
     * 导出缴费记录明细列表
     */
    @RequiresPermissions("business:payrecordd:export")
    @Log(title = "缴费记录明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public void export(HttpServletResponse response, SchoolPayrecordd schoolPayrecordd)
    {
        List<SchoolPayrecordd> list = schoolPayrecorddService.selectSchoolPayrecorddList(schoolPayrecordd);
        ExcelUtil<SchoolPayrecordd> util = new ExcelUtil<SchoolPayrecordd>(SchoolPayrecordd.class);
        util.exportExcel(response, list, "缴费记录明细");
    }

    /**
     * 获取缴费记录明细详细信息
     */
    @RequiresPermissions("business:payrecordd:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(schoolPayrecorddService.selectSchoolPayrecorddById(id));
    }

    /**
     * 新增缴费记录明细
     */
    @RequiresPermissions("business:payrecordd:add")
    @Log(title = "缴费记录明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SchoolPayrecordd schoolPayrecordd)
    {
        return toAjax(schoolPayrecorddService.insertSchoolPayrecordd(schoolPayrecordd));
    }

    /**
     * 修改缴费记录明细
     */
    @RequiresPermissions("business:payrecordd:edit")
    @Log(title = "缴费记录明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SchoolPayrecordd schoolPayrecordd)
    {
        return toAjax(schoolPayrecorddService.updateSchoolPayrecordd(schoolPayrecordd));
    }

    /**
     * 删除缴费记录明细
     */
    @RequiresPermissions("business:payrecordd:remove")
    @Log(title = "缴费记录明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(schoolPayrecorddService.deleteSchoolPayrecorddByIds(ids));
    }
}
